home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 168 / library / lib.doc < prev    next >
Text File  |  1988-04-30  |  8KB  |  257 lines

  1. exit(n) int n;
  2.     Exit a program; N is the program return value.
  3.  
  4. getopt(argc, argv, optstr) char *argv[], *optstr;
  5.     Parses a programs argument vector.  The optstr argument lists all 
  6.     possible program options, e.g. "abc:d" says that there are four
  7.     options: a, b, c, and d, with c requiring an argument.  The function
  8.     returns the option or EOF when no more are present.  For options that
  9.     require an argument, the argument is found in "optarg", a 
  10.     global char pointer.  See a UNIX manual for more info.
  11.  
  12. fprintf(fp, fmt, args) FILE *fp; char *fmt; int args;
  13.     A printf that writes to a standard I/O file.
  14.  
  15.     
  16. printf(fmt, args) char *fmt; int args;
  17.     A function that prints a formatted output string to standard output.
  18.  
  19. fscanf(f, fmt, args) FILE *f; char *fmt; int *args;
  20.     A scanf that reads a standard I/O file.
  21.  
  22. scanf(fmt, args) char *fmt; int *args; 
  23.     A function that reads arguments from the keyboard.
  24.  
  25. sscanf(s, fmt, args) char *s; char *fmt; int *args;
  26.     A scanf that reads from the given string.
  27.  
  28. fileno(s) FILE *s;
  29.     Returns the TOS file descriptor associated with a standard I/O stream.
  30.  
  31. fread(buf, sz, n, s) char *buf; FILE *s; 
  32.     Read a standard I/O stream into buf.  The sz is the size of each 
  33.     element    and n is the number of elements.
  34.  
  35. fwrite(buf, sz, n, s) char *buf; FILE *s;
  36.     Write buf onto a standard I/O stream.  The sz is the size of each
  37.     element and n is the number of elements.
  38.  
  39. fseek(s, offset, mode) FILE *s; long offset;
  40.     Seek to a particular location on a standard I/O stream.  See TOS
  41.     documentation.
  42.  
  43. fclose(s) FILE *s; 
  44.     Close a standard I/O stream.
  45.  
  46. char *
  47. fgets(b, n, f) char *b; int n; FILE *f; 
  48.     Read a string, at most n characters, into buffer b from stream f.
  49.     Keeps the newline.  Returns EOF if nothing is there.
  50.  
  51. FILE *
  52. fopen(name, mode) char *name, *mode;
  53.     Open a standard I/O stream.  Modes can be "r" for read, "w" for write,
  54.     "a" for append.  Can also handle "CON:", "PRT:", and "AUX:" to
  55.     get access to keyboard/console, printer, and auxiliary ports.
  56.  
  57. fputs(s, f) char *s; FILE *f;
  58.     Write a string onto a standard I/O stream.
  59.  
  60. char *
  61. gets(b) char *b; 
  62.     Get a string from stdin.  Drop the trailing newline.  Returns EOF
  63.     if nothing is there.
  64.  
  65. getchar()
  66.     Get a character from stdin.  Returns EOF if nothing is there.
  67.  
  68. getc(s) FILE *s;
  69.     Get a character from a standard I/O stream.  Returns EOF if nothing
  70.     is there.
  71.  
  72. putchar(c) 
  73.     Write a character onto stdout.
  74.  
  75. puts(s) char *s;
  76.     Write a string onto stdout.  Adds a newline.
  77.  
  78. putc(c, s) int c; FILE *s;
  79.     Write a character onto the given standard I/O stream.  This is a 
  80.     buffered write.
  81.  
  82. fflush(s) FILE *s;
  83.     Flush the output buffer associated with the standard I/O stream.
  84.  
  85. dup(fd)
  86.     A TOS routine to duplicate a file descriptor.
  87.  
  88. exec(file, args, env, mode) char *file, *args, *env; int mode;
  89.     Execute a program.  The file argument is the path of the program
  90.     to be executed.  The args argument will form the programs argv[],
  91.     it is like a string, except that the first byte must contain
  92.     the length of the string (ask TOS why).  I always use a mode of 0
  93.     to load-and-run a program.
  94.  
  95. getdir(buf, drive) char *buf;
  96.     Get the current directory of a given drive. If drive = 0, use
  97.     current drive.  Drive = 1 implies A:, 2 B:, etc.
  98.  
  99. listdir(pat, buf, mode) char *pat, *buf;
  100.     List a directory.  The pat argument is the pattern (e.g. *.C).  The
  101.     buf argument is a DTA buffer (see a TOS manual).  This function is
  102.     designed to be called many times, each call returning another match
  103.     to the search pattern in buf.  On the second and subsequent calls,
  104.     pat should be NULL.  A return of zero indicates success, non-zero
  105.     indicates error or end.  The mode argument also limits the search
  106.     based on the files's attributes.  I use 0 for files and 0x10 for 
  107.     directories.  In the DTA buffer, bytes 30 through 43 are the program
  108.     name.
  109.  
  110.  
  111. lseek(fd, offset, mode) int fd; long offset; int mode;
  112.     Set the file pointer for the given file descriptor fd.  If mode = 0,
  113.     offset directly sets the file pointer.  If mode = 1, offset is added
  114.     to the current file pointer.  If mode = 2, the file pointer is set
  115.     offset bytes past the current end of the file.
  116.  
  117. unlink(name) char *name;
  118.     Remove the named file.
  119.  
  120. close(fd)
  121.     Close a file.
  122.  
  123. creat(f, m) char *f;
  124.     Create a file named f with attributes m.
  125.  
  126. open(f, m) char *f;
  127.     Open a file named f.  If m = 0, read only.  If m = 1, write only.
  128.     If m = 3, read or write.
  129.  
  130.  
  131. read(fd, buf, sz) int fd, sz; char *buf;
  132.     Read sz bytes of file fd into buffer buf starting at the current
  133.     file pointer.  This advances the file pointer sz bytes.  Note, sz
  134.     is an integer!  Returns the number of bytes read.
  135.  
  136. write(fd, buf, sz) int fd, sz; char *buf;
  137.     Write sz bytes of buffer buf onto file fd.
  138.  
  139. chmod(name, mode) char *name; int mode;
  140.     Change the attributes of a file.
  141.      * mode = 0x00 - normal file (read/write)
  142.      *        0x01 - read only file
  143.      *        0x02 - hidden file
  144.      *        0x04 - system file
  145.      *        0x08 - file is volume label
  146.      *        0x10 - file is a subdirectory
  147.      *        0x20 - file is written and closed correctly
  148.  
  149. sprintf(buf, fmt, args)    char *buf, *fmt; int args;
  150.     A printf that stores the formatted output into buf instead of
  151.     writing it out.
  152.  
  153. char *
  154. realloc(r, n) struct header *r; unsigned n;
  155.     Change the size of a malloc'ed piece of memory.
  156.  
  157. char *
  158. calloc(n, sz) unsigned n, sz;
  159.     Allocate sz bytes and zero them out.
  160.  
  161. char *
  162. malloc(n) unsigned n; {
  163.     Allocate n bytes from the system.  
  164.  
  165. free(r) struct header *r;
  166.     Return a previously allocated piece of memory back to the system.
  167.  
  168. char *
  169. strcat(s1, s2) char *s1, *s2; {
  170.     Concatenate string s2 onto string s1.  Returns a pointer to s1.
  171.  
  172. char *
  173. strncat(s1, s2, n) char    *s1, *s2; int n;
  174.     Concatenate string s2 onto string s1, which is no more than n bytes
  175.     long.
  176.  
  177. strcmp(s1, s2) char *s1, *s2; 
  178.     Compare string s1 to string s2.  Returns less than, equal, or greater
  179.     than zero if the s1 is less than, equal, or greater than s2.
  180.  
  181. strncmp(s1, s2, n) char    *s1, *s2; int n;
  182.     Same as strcmp, except that it only looks at n characters.
  183.  
  184. char *
  185. strcpy(s1, s2) char *s1, *s2;
  186.     Copy string s2 into string s1;
  187.  
  188. char *
  189. strncpy(s1, s2, n) char *s1, *s2; int n;
  190.     Same as strcpy except it copies at most n characters.
  191.  
  192. strlen(s) char *s;
  193.     Returns the length of a string.
  194.  
  195. char *
  196. strchr(s, c) char *s; int c;
  197.     Searches string s for character c.  Returns a pointer to the
  198.     first occurence or NULL if not found.
  199.  
  200. char *
  201. strrchr(s, c) char *s; int c;
  202.     Same as strchr(), except it searches from the end of the string
  203.     towards the beginning.
  204.  
  205. char *
  206. strpbrk(s1, s2) unsigned char *s1, *s2;
  207.     Scans over the string in s1 looking for characters in string s2.
  208.     Stops at the first occurence and returns a pointer to its location.
  209.     Returns NULL if it didn't find anything.
  210.  
  211. char *
  212. strtok(s1, s2) unsigned char *s1, *s2;
  213.     Tokenizes a string s1.  The first call should have a non-NULL s1,
  214.     which is remembered on subsequent calls.  String s2 contains the
  215.     token separators.
  216.  
  217. strspn(s1, s2) unsigned char *s1, *s2;
  218.     Skips over the string s1 as long as it contains the characters
  219.     found in string s2.  Returns a pointer into s1.
  220.  
  221. strcspn(s1, s2) unsigned char *s1, *s2;
  222.     Same as strspn, except the inverse condition (i.e. skips s1 as long
  223.     as it does not contain s2 characters).
  224.  
  225. long 
  226. strtol(s, p, base) char    *s, **p;
  227.     Convert a number in a string to a (long) integer.  Handles octal
  228.     and hex constants as well as decimal.  If p is non-NULL, the end
  229.     of the number is stored there.
  230. char *
  231. strlower(s) char *s;
  232.     Convert all uppercase characters in s to lowercase.
  233.  
  234. char *
  235. strupper(s) char *s;
  236.     Convert all lowercase characters in s to uppercase.
  237.  
  238. memcpy(m1, m2, n) char *m1, *m2;
  239.     Copy n bytes from m2 to m1.
  240.  
  241. long
  242. time(tloc) long *tloc;
  243.     Return the number of seconds since 1980.  If tloc is non-nil, then
  244.     the value is stored there as well.
  245.  
  246. getdate()
  247. gettime()
  248.     Get the current date and time in TOS format.
  249.  
  250. setjmp(buf) char **buf;
  251.     Initializes a buffer to allow one to do a non-local goto.  
  252.     See a UNIX manual.
  253.  
  254. longjmp(buf, rc) char **buf;
  255.     Actually do the non-local goto.
  256.  
  257.